package com.example.sxproject.service.impl;

import com.example.sxproject.mapper.CompanyMapper;
import com.example.sxproject.pojo.Company;
import com.example.sxproject.pojo.FinancialProduct;
import com.example.sxproject.pojo.Result;
import com.example.sxproject.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;


@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    // 查询：返回全部
    @Override
    public List<Company> selectAll() {
        List<Company> companies = companyMapper.selectAll();
        return companies;
    }

    // 查询：返回指定账号内容
    @Override
    public Company findByCount(String companyCount) {
        Company company = companyMapper.findByCount(companyCount);
        return company;
    }

    // 查询：返回指定城市内容
    @Override
    public List<Company> searchCompany(String search) {
        List<Company> companies = companyMapper.searchCompany(search);
        return companies;
    }

    // 根据城市查询对应的公司列表
    @Override
    public List<Company> getCompaniesByCity(String city) {
        List<Company> companies = companyMapper.findCompaniesByCity(city);
        return companies;
    }

    @Override
    public Company getCompanyAccount(String city, String companyName) {
        Company company = companyMapper.findByCityAndCompanyName(city, companyName);
        return company;
    }

    //添加insert：添加一个公司
    @Override
    public void addCompany(Company company) {
        companyMapper.addCompany(company);
    }

    //更新update：修改公司信息
    @Override
    public void updateCompany(Company company) {
        companyMapper.updateCompany(company);
    }

    //更新update：根据id进行假删除
    @Override
    public void deleteCompany(Company company) {
        companyMapper.deleteCompany(company);
    }

    @Override
    public  List<Company> selectCompanyByCT(Company company){
        List<Company> companies = companyMapper.selectCompanyByCT(company);
        return companies;
    }

    @Override
    public void companyDel(Integer id){
        companyMapper.companyDel(id);
    }
}
